Bundle the 8 math fonts (assets, plists, licenses, load test)#209
Conversation
TDD red step: testAllBundledFontsLoad iterates all 8 expected font keys and asserts each loads with a non-nil font and mathTable. Test fails (crashes on missing font files) because newcm-math, texgyrepagella-math, stixtwo-math, firamath, and notosansmath are not yet bundled. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the bundled fonts and their licenses, modifies the math_table_to_plist.py script to ignore device tables instead of raising exceptions, and adds a test to verify that all bundled fonts load correctly. Feedback on the new test points out that asserting font is not nil is redundant because fontWithName:size: always returns an instance; instead, the test should assert that the internal CoreText font (font.ctFont) is not NULL to ensure successful loading.
| MTFont* font = [[MTFontManager fontManager] fontWithName:key size:20]; | ||
| XCTAssertNotNil(font, @"Font %@ failed to load", key); | ||
| XCTAssertNotNil(font.mathTable, @"Font %@ has no math table", key); |
There was a problem hiding this comment.
The assertion XCTAssertNotNil(font, ...) is redundant and misleading because -[MTFontManager fontWithName:size:] always returns a non-nil MTFont instance (even if the underlying .otf or .plist files fail to load). To properly verify that the font files were successfully located and loaded, you should assert that the font's internal CoreText font (font.ctFont) is not NULL.
MTFont* font = [[MTFontManager fontManager] fontWithName:key size:20];
XCTAssertNotNil(font.mathTable, @"Font %@ has no math table", key);
XCTAssertTrue(font.ctFont != NULL, @"Font %@ failed to load CTFont", key);There was a problem hiding this comment.
Fixed in 2510bac. fontWithName:size: always returns a non-nil MTFont, so the original XCTAssertNotNil(font) was a tautology. Replaced it with XCTAssertTrue(font.ctFont != NULL, ...) to verify the .otf actually loaded.
fontWithName:size: always returns a non-nil MTFont, so XCTAssertNotNil(font) proved nothing. Assert font.ctFont != NULL to verify the .otf actually loaded. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Goal
Ship all 8
<key>.otf+<key>.plistpairs and their license/attribution files underiosMath/fonts/, and prove every key loads. No API or example-app change. Buildable & testable in isolation (swift test).Plan:
docs/plans/2026-05-30-add-math-fonts.md(items 1–8)LLD:
docs/lld/2026-05-30-add-math-fonts.mdCommits
[item 1]Add failing load test for all 8 bundled fonts[item 2]Update XITS Math to v1.302 and regenerate plist[item 3]Add New Computer Modern Math font + plist[item 4]Add TeX Gyre Pagella Math font + plist[item 5]Add STIX Two Math font + plist[item 6]Add Fira Math font + plist[item 7]Add Noto Sans Math font + plist[item 8]Document the 8 bundled fonts and licenses in READMEFont versions bundled
xits-mathnewcm-mathtexgyrepagella-mathstixtwo-mathfiramathnotosansmathTesting
All 267 tests pass.
testAllBundledFontsLoadverifies every key resolves its.otf+.plistpair.No
Package.swiftor.xcodeprojedits needed — all three build systems bundlefonts/as a folder reference.